import socket

udp_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
# udp_socket.sendto(信息,地址(IP+端口)必须是元祖)
udp_socket.bind(('127.0.0.1', 8000))
def main():
    while True:
        msg,addr=udp_socket.recvfrom(1024)
        print(msg.decode('utf-8'))
        msg=input('>>>>>>')
        udp_socket.sendto(msg.encode('utf-8'),addr)

    udp_socket.close()
if __name__ == '__main__':
    main()